<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>焦点图上传</title>
<link href="../css/H-ui.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../lib/layer/1.9.3/layer.js"></script>
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/ajaxfileupload.js"></script>
<script type="text/javascript" src="js/artDialog4.1.6/jquery.artDialog.js?skin=default"></script>
<script type="text/javascript" src="js/artDialog4.1.6/plugins/iframeTools.js"></script>
<script type="text/javascript" src="../../lib/layer/1.9.3/layer.js"></script>
<script type="text/javascript" >

$(document).ready(function(e){
		
	$('#head_photo').live('change',function(){ 
		ajaxFileUploadview('head_photo','photo_pic',"upload.php");
	});	

});


function insql(file){
	
	//判断是否为焦点图是跳转回之前页面
	layer.msg('上传成功!',{icon: 1,time:2000});
	window.location.href='../Picture_List.php?title=登录';/* 	window.location.href="../Picture_List.php?title=登录";
		layer.msg('上传成功!',{icon: 1,time:1000}); */
//否更新图片显示
		//$("#head_photo_src").attr('src',head_file);	
}

//文件上传带预览
function ajaxFileUploadview(imgid,hiddenid,url){
		var pictype="登录";
		var info="焦点图";
		$('#loading').fadeIn();//显示加载ing
		$.ajaxFileUpload
		({
			url:url,
			secureuri:false,
			fileElementId:imgid,
			dataType: 'json',
			data:{name:'logan', id:'id'},
			success: function (data, status)
			{	
		$('#file').hide();//隐藏文件选择按钮
				$('#loading').fadeOut();//隐藏加载ing
				if(typeof(data.error) != 'undefined')
				{
					if(data.error != '')
					{
						layer.msg(data.error,{icon: 2,time:1500});//警告提示
						$('#file').show();//显示文件选择按钮
						/*var dialog = art.dialog({title:false,fixed: true,padding:0});
						dialog.time(2).content("<div class='tips'>"+data.error+"</div>");*/
					}else{

						var resp = data.msg;						
						if(resp != '0000'){
							var dialog = art.dialog({title:false,fixed: true,padding:0});
							dialog.time(2).content("<div class='tips'>"+data.error+"</div>");
							return false;
						}else{
							$('#'+hiddenid).val(data.imgurl);						

							art.dialog.open("crop_image.php?img="+data.imgurl+"&pictype="+pictype+"&info="+info,{
							//裁剪页面大小
								title: '图片裁剪',
								width:'70%',
								height:'400px'
							});						
							
							dialog.time(3).content("<div class='msg-all-succeed'>上传成功！</div>");
						}
									

						
						
					}
				}
			},
			error: function (data, status, e)
			{

				dialog.time(3).content("<div class='tips'>"+e+"</div>");
			}
		})

		return false;
	}</script>
<style type="text/css">
body{
	padding:0; margin-left:50px;margin-top:50px; font-size:12px;  color:#333333; font-family:'宋体',Verdana, Geneva, sans-serif;
}
.tips{padding:10px;color:red;margin-top:20px;}
</style>

</head>
<body>
<div id="file" class="text-c">
<span class="btn-upload">
<a href="javascript:void();" class="btn btn-primary radius" >选择文件</a>
<input type="file" name="head_photo" id="head_photo" class="input-file" value="">  
</span>
</div>
<div class="text-c" id="loading" style="display:none;" >
<img style="margin-top:50px; width:100px;height:100px;" id="" src="images/loadingBar.gif">
<div>文件检测上传中...</div>
</div>
<input type="hidden" name="photo_pic" id="photo_pic" value="">
</body>
</html>